﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using EShop.Common;
using EShop.BLL;
using EShop.Model;

namespace EShop.Client
{
    public partial class frmMerchandiseClassAppend :frmBase
    {
        public frmMerchandiseClassAppend()
        {
            InitializeComponent();
            Reset();
        }

        private void Reset()
        {
            this.txtMerchandiseClassName.Clear();
            this.rtbMerchandiseClassResume.Clear();
            this.rtbMerchandiseClassRemark.Clear();
        }

        private void btnReset_Click(object sender, EventArgs e)
        {
            Reset();
        }

        private void btnApend_Click(object sender, EventArgs e)
        {
            string strMerchandiseClassName = SystemLibrary.SQLQuoteName(txtMerchandiseClassName.Text.Trim());
            string strMerchandiseClassResume = SystemLibrary.SQLQuoteName(rtbMerchandiseClassResume.Text);
            string strMerchandiseClassRemark = SystemLibrary.SQLQuoteName(rtbMerchandiseClassRemark.Text);
            if (string.IsNullOrEmpty(strMerchandiseClassName))
            {
                MessageBox.Show("请填写商品类型名称！");
                txtMerchandiseClassName.Focus();
                return;
            }
            if (string.IsNullOrEmpty(strMerchandiseClassResume))
            {
                MessageBox.Show("请对添加的商品类型进行一定的描述！");
                rtbMerchandiseClassResume.Focus();
                return;
            }
            EShop.Model.MerchandiseClass oMerchandiseClass = new EShop.Model.MerchandiseClass();
            EShop.BLL.MerchandiseClassBLL oMerchandiseClassBLL = new EShop.BLL.MerchandiseClassBLL();
            oMerchandiseClass.MerchandiseClassName = strMerchandiseClassName;
            oMerchandiseClass.MerchandiseClassResume = strMerchandiseClassResume;
            oMerchandiseClass.MerchandiseClassRemark = strMerchandiseClassRemark;
            if (oMerchandiseClassBLL.AppendMerchandiseClass(oMerchandiseClass))
            {
                MessageBox.Show(string.Format("商品类型:{0} 添加成功！", strMerchandiseClassName));
                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show(string.Format("商品类型:{0} 添加操作失败！", strMerchandiseClassName));
                this.DialogResult = DialogResult.Cancel;
                this.Close();
            }

        }

        private void frmMerchandiseClassAppend_Load(object sender, EventArgs e)
        {

        }
    }
}
